package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemotePartnerinfoService;
import com.ruoyi.system.api.domain.Partnerinfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;

public class RemotePartnerinfoFallbackFactory implements FallbackFactory<RemotePartnerinfoService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteLogFallbackFactory.class);

    @Override
    public RemotePartnerinfoService create(Throwable throwable) {

        // 记录错误日志
        log.error("远程调用失败，进入降级处理", throwable.getMessage());
        System.out.println("用户调用服务失败：{}"+throwable.getMessage());
        return new RemotePartnerinfoService() {
            @Override
            public R<Partnerinfo> getInfo1(Long partnerId) {
                return R.fail("远程调用失败，返回默认值" +throwable.getMessage());
            }
        };
    }
}
